function addUser() {
    Ajax.getHtml('/userAdd.html', function (html) {
        layer.open({
            type: 1,
            title: '新增用户',
            area: ['800px',['400px']],
            content: html,
            btn: ['确认', '取消'],
            yes: function () {
                saveUser()
            },
            btn2: function () {
                console.log('bbbb')
            }
        })

    })
}

function saveUser() {

    var status='';
    var radio=document.getElementsByName("stateCode");
    for (var i =0;i<radio.length;i++){
        if (radio[i].checked){
            status=radio[i].value;

        }
    }
    var radio2 = document.getElementsByName("power");
    var powers='';
    for (var i = 0;i<radio2.length;i++){
        if (radio2[i].checked ===true){
            var a=radio2[i].value;
            powers = powers+a+","
        }
    }
    Ajax.post(
        '/addUser',
        {
            account:$('#account').val(),
            name:$('#name').val(),
            password:$('#password').val(),
            status:status,
            powers:powers
        },
        function (result) {
            doResult(result, function () {
                layer.closeAll()
                show('userList.html')
                layer.alert(result.msg)
            })
        }
    )
}
function dele(Obj) {
    var flat= window.confirm('确认删除?');
    if (flat==true) {
        var id = Obj.id;
        Ajax.post(
            "/deleteUser",
            {
                account:id
            },
            function (result) {
                doResult(result, function () {

                    show('userList.html')

                })
            }
        )
    }else {
        return false;
    }


}

function updatePoMain(Obj) {
    Ajax.post("updatePoMain1",{
        poID:Obj
    },function (reslut) {
        $('#main').load("updatePoMain.html",function () {
            $('#POID').val(reslut.data.poID);
            $('#createDate').val(reslut.data.createTime);
            $('#account').val(reslut.data.account);
            $('#tipFee').val(reslut.data.tipFee);
            $('#productTotal').val(reslut.data.productTotal);
            $('#prePayFee').val(reslut.data.prePayFee);
            $('#remark').val(reslut.data.remark);
        })
        // show('updatePoMain.html');

    })
}


function selectSoMain() {
    var date = $('#timeRange').val();
    var soID = $('#soID').val();
    var status =$('#status').find("option:selected").val();
   showPage({
       currentPage:1,
       pageSize:3,
       url:'selectSoMain',
       templateId:'soMainTemplate',
       contentId:'soMainBody',
       params:{
           date:date,
           soID:soID,
           status:status
       }
   })
}

function getSoItem(soID){
    Ajax.getHtml('soItem.html',function (html) {
        Ajax.post("getSoItem",{
            soID:soID
        },function (result) {
            var str =template("poItems",result);
            document.getElementById("poItem").innerHTML=str;
            doResult(result,function () {

            })
        });
        layer.open({
            type:1,
            title:'明细查看',
            area: ['800px',['400px']],
            content: html,
            btn: ['确认', '取消'],
            yes:function () {
                layer.closeAll();
            }
        })
    });
}


function getPoItem(Obj){
    Ajax.getHtml("poItem.html",function (html) {
        Ajax.post("getPoItem",{
            poID:Obj
        },function (result) {
            var str =template("poItems",result);
            document.getElementById("poItem").innerHTML=str;
            doResult(result,function () {

            })
        });

        layer.open(
            {
                type:1,
                title:'明细查看',
                area: ['800px',['400px']],
                content: html,
                btn: ['确认', '取消'],
                yes:function () {
                    layer.closeAll();
                }
            })
    });


}
Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "H+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}